package com.example.designer.iter.impl;

import com.example.designer.iter.inte.Menu;
import com.example.designer.iter.pojo.Foot;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * 集合实现的菜单类
 */
public class ListMenu implements Menu {

    List<Foot> footList;

    public ListMenu() {
        this.footList = new ArrayList<>();
        addItem(10,"包子");
        addItem(10,"饺子");
        addItem(10,"馅饼");
        addItem(10,"粥");
    }

    public void addItem(Integer price, String name) {
        Foot foot = new Foot(price, name);
        footList.add(foot);
    }



    @Override
    public Iterator<Foot> createIterator() {
        return new ListIterator(footList);
    }
}
